Skip to content

test: add unit tests for keyword modules#473

Open
Dor-bl wants to merge 2 commits into
serhatbolsu:masterfrom
Dor-bl:feat/add-keyword-tests
Open

test: add unit tests for keyword modules#473
Dor-bl wants to merge 2 commits into
serhatbolsu:masterfrom
Dor-bl:feat/add-keyword-tests

Conversation

@Dor-bl

@Dor-bl Dor-bl commented Feb 1, 2026

Copy link
Copy Markdown
Contributor
  • Add tests for _keyevent.py (100% coverage)
  • Add tests for _runonfailure.py (81% coverage)
  • Add tests for _screenshot.py (100% coverage)
  • Add tests for _screenrecord.py (57% coverage)
  • Add tests for _waiting.py (100% coverage)

Improves overall test coverage from 33% to 39%

Implements

This pull request adds comprehensive unit tests for several internal keyword classes in the AppiumLibrary, significantly improving test coverage for key functionalities such as key events, run-on-failure behavior, screen recording, screenshots, and waiting mechanisms. The new tests use Python's unittest framework and extensive mocking to verify correct behavior under various scenarios, including edge cases and error handling.

New Unit Test Coverage:

  • Key Event Keywords:

    • Added tests for _KeyeventKeywords, covering press_keycode and long_press_keycode methods, including handling of meta states and string-to-int conversion.
  • Run-On-Failure Keywords:

    • Introduced tests for _RunOnFailureKeywords, verifying registration, state transitions, disabling, and error reporting logic for run-on-failure keywords.
  • Screen Recording Keywords:

    • Implemented tests for _ScreenrecordKeywords, checking start/stop behavior, time limits, output format handling, prevention of duplicate recordings, and error handling for missing sessions.
  • Screenshot Keywords:

    • Added tests for _ScreenshotKeywords, ensuring correct screenshot capture with and without filenames, file saving, fallback mechanisms, subdirectory handling, and HTML embedding.
  • Waiting Keywords:

    • Developed tests for _WaitingKeywords, covering sleep interval management, timeout formatting, and all major wait-until behaviors (element/text presence/absence), including error and edge cases.

- Add tests for _keyevent.py (100% coverage)
- Add tests for _runonfailure.py (81% coverage)
- Add tests for _screenshot.py (100% coverage)
- Add tests for _screenrecord.py (57% coverage)
- Add tests for _waiting.py (100% coverage)

Improves overall test coverage from 33% to 39%
@emanlove emanlove added enhancement Acknowledge Acknowledge within Release Notes needs review labels Feb 2, 2026

@chsinger chsinger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @Dor-bl, solid test additions — I ran the suite on your branch and after a test-merge onto current master, all green. Two small suggestions below.

Comment thread tests/keywords/test_waiting.py Outdated
Comment thread tests/keywords/test_screenrecord.py Outdated
@Dor-bl

Dor-bl commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Applied the suggestions! Thank you for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Acknowledge Acknowledge within Release Notes enhancement needs review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants